package com.tjhk.netty.test.model;


import com.tjhk.netty.model.Message;
import com.tjhk.netty.serialize.DataType;
import com.tjhk.netty.serialize.annotation.Field;

import java.nio.charset.Charset;
import java.time.LocalDateTime;

public class MyMessage implements Message {

    private Integer messageId;

    private String body;

    @Field(index = 0,length = 1,type = DataType.BYTE,desc = "年龄")
    private Integer age;

    @Field(index = 1,length = 6,type = DataType.BCD8421,desc = "出生年月")
    private LocalDateTime birthday;

    @Field(index = 2,length = 4,type = DataType.STRING,desc = "姓名")
    private String name;

    @Field(index = 3,length = 8,type = DataType.BYTES,desc = "需要自己转换的字段")
    private byte[] dynamic;

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public byte[] getDynamic() {
        return dynamic;
    }

    public void setDynamic(byte[] dynamic) {
        this.dynamic = dynamic;
    }

    public LocalDateTime getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDateTime birthday) {
        this.birthday = birthday;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getBody() {
        return body;
    }

    public void setMessageId(Integer messageId) {
        this.messageId = messageId;
    }

    @Override
    public Integer getMessageId() {
        return this.messageId;
    }

    @Override
    public String toString() {
        return "MyMessage{" +
                "messageId=" + messageId +
                ", body='" + body + '\'' +
                ", birthday=" + birthday +
                ", age=" + age +
                ", name='" + name + '\'' +
                ", dynamic=" + new String(dynamic, Charset.forName("GBK")) +
                '}';
    }
}